import request from '@/utils/request'
import qs from 'qs'
import type { strategyRespnseData,liketype,reqtype,strategyObject} from './type'
export function getstrategydata():Promise<strategyRespnseData>  {
  const url = '/strategy/strategydata'
  return request({
    url: url,
    method: 'get'
  })
}

export function reqlike(data: liketype):Promise<reqtype>  {
  const url = '/strategy/getlike'
  return request({
    url: url,
    method: 'post',
    data: data,

    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function reqcollect(data: string, id: number) :Promise<reqtype> {
  const url = '/strategy/getcollect'
  return request({
    url: url,
    method: 'post',
    data: { data: JSON.stringify(data), id: id },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function write(data: strategyObject):Promise<reqtype> {
  const url = '/strategy/write'
  return request({
    url: url,
    method: 'post',
    data: JSON.stringify(data),
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export function update(data:strategyObject):Promise<reqtype> {
  const url = '/strategy/update'
  return request({
    url: url,
    method: 'post',
    data: JSON.stringify(data),
  headers: {
    'Content-Type': 'application/json'
  }
  })
}


export function deletestrategydata(id:string):Promise<reqtype> {
  const url = '/strategy/delete'
  return request({
    url: url,
    method: 'post',
    data: qs.stringify({id}),
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
  })
}
